# -*- coding: UTF-8 -*-
import configparser

import pandas as pd
from sqlalchemy import create_engine

cf = configparser.ConfigParser()
cf.read("config.ini", encoding='gbk')  # 读取配置文件，如果写文件的绝对路径，就可以不用os模块
# 获取文件中所有的section(一个配置文件中可以有多个配置，如数据库相关的配置，邮箱相关的配置，
# 每个section由[]包裹，即[section])，并以列表的形式返回
secs = cf.sections()
print("cf.sections()",secs)

options = cf.options("BaseConfig")
print("cf.options(BaseConfig)",options)

items = cf.items("BaseConfig")
print(items[1])

host = cf.get("BaseConfig", "program")
print(host)
host = cf.get("DataBaseConfig", "host")
user = cf.get("DataBaseConfig", "user")
pwd = cf.get("DataBaseConfig", "password")
db = cf.get("DataBaseConfig", "db")
db_str="mysql+pymysql://"+user+":"+pwd+"@"+host+"/"+db+"?charset=utf8mb4"
# 连接数据库
engine_ts  = create_engine(db_str,echo=False,max_overflow=5)
SQL="SELECT * FROM stock_all_data WHERE ts_code='300663.SZ' AND k_type='日线'"
df =pd.read_sql(SQL,engine_ts)
print(df)
# xxxx=engine_ts.execute("SELECT * FROM stock_all_data WHERE ts_code='300663.SZ' AND k_type='日线'")
# print(engine_ts)
# # 执行SQL语句
# print(type(xxxx))
#    # 获取所有记录列表
# results = xxxx.fetchall()
# for row in results:
#     fname = row[0]
#     print(fname)
# print("end")


str = input("请输入：")
print("你输入的内容是: ", str)